Skip to content

Close file handles before pg_fatal outside pg_upgrade#2

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-pg-fatal-exit-1
Draft

Close file handles before pg_fatal outside pg_upgrade#2
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-pg-fatal-exit-1

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 18, 2026

pg_fatal exits immediately and was leaving FILE* descriptors open on error paths in several client utilities (pgbench, pg_basebackup, pg_createsubscriber, pg_waldump, astreamer), risking buffered data loss and leaked handles.

  • pgbench: close stdin/file on read error before pg_fatal.
  • pg_basebackup: close manifest FILE* (and null it) on fwrite failure in streaming callbacks.
  • pg_createsubscriber: close recovery config FILE* before fatal write failure.
  • pg_waldump: close page dump FILE* before fatal write failure.
  • fe_utils astreamer: close and null extracted file handle before fatal write failure.

Example:

if (fwrite(page, BLCKSZ, 1, file) != 1)
{
    int save_errno = errno;
    fclose(file);
    errno = save_errno;
    pg_fatal("could not write file \"%s\": %m", filename);
}

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@cr-gpt
Copy link
Copy Markdown

cr-gpt Bot commented Mar 18, 2026

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Co-authored-by: yjhjstz <3832082+yjhjstz@users.noreply.github.com>
@cr-gpt
Copy link
Copy Markdown

cr-gpt Bot commented Mar 18, 2026

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copilot AI changed the title [WIP] Fix pg_fatal to properly release file descriptors on exit Close file handles before pg_fatal outside pg_upgrade Mar 18, 2026
Copilot AI requested a review from yjhjstz March 18, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants